<?php
final class PHPKJ{
	public static function run(){
		self::_set_const();   
		self::_create_dir();
		self::_import_file();
		Application::run();
	}


	//定义框架目录路径
	private static function _set_const(){    
		//D:\wamp\www\KJ\PHPKJ\PHPKJ\PHPKJ.php
		//var_dump(__FILE__);
		$path = str_replace('\\', '/', __FILE__);
		define('PHPKJ_PATH',dirname($path));   // D:\wamp\www\KJ\PHPKJ\PHPKJ\PHPKJ.php
		define('CONFIG_PATH',PHPKJ_PATH . '/Config');
		define('DATA_PATH', PHPKJ_PATH . '/Data');
		define('LIB_PATH',PHPKJ_PATH . '/Lib');
		define('CORE_PATH',LIB_PATH . '/Core');
		define('FUNCTION_PATH', LIB_PATH . '/Function');

		define('ROOT_PATH',dirname(PHPKJ_PATH));   //定义根目录
		define('APP_PATH',ROOT_PATH . '/' . APP_NAME);
		define('APP_CONFIG_PATH',APP_PATH . '/Config');
		define("APP_CONTROLLER_PATH",APP_PATH . '/Controller');
		define('APP_TPL_PATH', APP_PATH . '/Tpl');
		define('APP_PUBLIC_PATH',APP_TPL_PATH . '/Public');

		
	}

	private static function _create_dir(){     //创建前后端文件目录
		$arr = array(
			APP_PATH,
			APP_CONFIG_PATH,
			APP_CONTROLLER_PATH,
			APP_TPL_PATH,
			APP_PUBLIC_PATH
		);

		foreach ($arr as $v){
			is_dir($v) || mkdir($v,0777,true);
		}


	}


	//载入框架所需文件
	private static function _import_file(){
		$fileArr = array(
			FUNCTION_PATH . '/function.php',
			CORE_PATH . '/Controller.class.php',
			CORE_PATH . '/Application.class.php'

		);

		foreach($fileArr as $v){
			require_once $v;
		}


	}






}



PHPKJ::run();

?>